// import Vue from 'vue'
// import Router from 'vue-router'
// import HelloWorld from '@/components/HelloWorld'

// Vue.use(Router)

// export default new Router({
//   routes: [
//     {
//       path: '/',
//       name: 'HelloWorld',
//       component: HelloWorld
//     }
//   ]
// })
import Vue from 'vue'
import VueRouter from 'vue-router'
// import Home from '../views/Home.vue'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    redirect: 'welcome',
    // component:() =>import('@/views/welcome')
  },
  {
    path: '/welcome',
    name: 'welcome',
    component: () => import('@/views/welcome')
  },
  {
    path: '/layout',
    name: 'layout',
    component: (resolve) => require(['@/views/layout/index.vue'], resolve),
    children: [
      {
        path: '/hmoe',
        name: 'home',
        component: () => import('@/views/home/index.vue')
      },
      {
          path: '/userManagement',
          name: 'userManagement',
          component: () => import('@/views/userManagement/index.vue' ),
          meta: {
              preTitle: '数据源',
              title: '数据源管理',
              titles: ['数据源', '数据源管理'],
              keepAlive: true
          }
      },
    ]
  },
  // {
  //     path: '/apiPortrait',
  //     name: 'apiPortrait',
  //     component: (resolve) => require(['@/views/apiManagement/apiPortrait/index.vue'], resolve),
  //     meta: {
  //         preTitle: '统一API管理',
  //         title: 'API画像',
  //         titles: ['统一API管理', 'API画像'],
  //         keepAlive: true
  //     }
  // },
  {
      path: '*',
      name: '404',
      component: (resolve) => require(['@/views/404/index.vue'], resolve)
  }
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
    return originalPush.call(this, location).catch((err) => err)
}

export default router
